<?php
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
$this->context->layout = false;
$form = ActiveForm::begin([
    'id' => 'm-form-earlyapply',
    'options' => [
        'class' => 'form-horizontal'
    ]
]);
?>
<?php
//使用率
echo $this->render("@app/views/public/useRate.php")
?>
<style>
    .text-center tr th {text-align:center;}
</style>
<div class="m-box">
                <table class="table table-bordered table table-hover text-center">
                    <thead class="text-center">
                    <tr >
                        <th>部門</th>
                        <th>组別</th>
                        <th>姓名</th>
                        <th>早班日期</th>
                        <th>申請早班日期</th>
                        <th>操作</th>
                        <th>原因</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($data as $k=>$v){ ?>
                    <tr>
                        <td><?=$v['department_name']?></td>
                        <td><?=$v['group_name']?></td>
                        <td><?=$v['name_en_long']?></td>
                        <td><?=$v['early_time']?></td>
                        <td><?=$v['early_apply_time']?></td>
                        <td id="Agreed"><select class="from-control" name="progress[]"><option value="2">同意</option><option value="3">不同意</option></td>
                        <td><input type="text" name="reason[]" style="width: 90%;height: 100%;" placeholder="不同意时请填写理由！"/></td>
                    </tr>
                        <input type="hidden" name="id[]" value="<?=$v['apply_id']?>"/>
                        <input type="hidden" name="early_apply_time[]" value="<?=$v['early_apply_time']?>"/>
                        <input type="hidden" name="early_time_id[]" value="<?=$v['early_time_id']?>"/>
                    <?php } ?>
                    </tbody>
                </table>
</div>
<br>
<div class="panel panel-default">
    <a type="button" class="k-button k-button-icontext" id="m-submit-earlyapply" href="javascript:;"
       style="margin-top:20px;float:right;"><i class="glyphicon glyphicon-plus"></i>提交</a>
</div>
<?php ActiveForm::end(); ?>
<script>
    $("#m-submit-earlyapply").click(function () {
        if($("#Agreed").children().val()==3){
            if ($("#Agreed").next().children().val()==""){
                layer.msg("不同意时请填写理由！", {icon: 5});
                return false;
            }
        }
        var _this = $(this);
        _this.parents("#m-form-earlyapply").ajaxSubmit({
            url: "<?=Url::to(['earlyapplylist']); ?>",
            dataType: "json",
            success: function (redata) {
                if (redata.status == 1) {
                    layer.msg(redata.info, {icon: 6});
                    earlyapplyWindow.data('kendoWindow').close();
                } else {
                    layer.msg(redata.info, {icon: 5});
                }
            }
        })
    })
</script>